class Solution(object):
    def sortJumbled(self, mapping, nums):
        def convert(num):
            s = str(num)
            t = ''
            for c in s:
                t += str(mapping[int(c)])
            return int(t)

        new_nums = [[convert(num), index] for index, num in enumerate(nums)]
        new_nums.sort(key=lambda x: (x[0], x[1]))
        return [nums[index] for _, index in new_nums]
